# Importing Data
BRAZIL<- read_excel("C:/users/Biniam/Desktop/Documents/Academic/Thesis/Analysis Folder/Excel Files/Aluminium/Aluminium.xlsx",sheet = "Sheet1", range = "G1:G264")

# Checking the Imported Data
View(BRAZIL)
# Creating Time Series Data
BRAZIL_ts <- ts(BRAZIL, start=c(1998,1), end=c(2018,12), frequency=12)
# Viewing and Checking the Created Time Series Data
BRAZIL_ts
sum(is.na(BRAZIL_ts))
library(forecast)
BRAZIL_ts <- tsclean(BRAZIL_ts)
BRAZIL_ts

# Identification: Plotting the Time Series Data
plot(BRAZIL_ts)

# Estimating the appropriate model
BRAZIL_ts_model <- auto.arima(BRAZIL_ts)
BRAZIL_ts_model

# Forecasting
options(max.print=1000000)
BRAZIL_ts_forecast <- forecast (BRAZIL_ts_model, level=c(95), h=364)
plot(BRAZIL_ts_forecast)
BRAZIL_ts_forecast             

# Exporting
write.table(BRAZIL_ts_forecast, file="/users/Biniam/Desktop/Documents/Academic/Thesis/Result Folder/TSA Results/Excel Files/From R/Aluminium/BRAZIL_TSA.csv", sep=",")
